package cn.wu.jishupeizhi.redisTest;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)
public class RedisZset {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @Test
    public void redisZsetAdd() {
        redisTemplate.opsForZSet().add("zsetTest", "a", 1);
        redisTemplate.opsForZSet().add("zsetTest", "b", 2);
        redisTemplate.opsForZSet().add("zsetTest", "c", 3);
    }

    @Test
    public void redisZsetGet() {
        System.out.println(redisTemplate.opsForZSet().range("zsetTest", 0, -1));
    }

    @Test
    public void redisZsetDel() {
        redisTemplate.opsForZSet().remove("zsetTest", "c");
    }
}
